﻿using System;

namespace FlipRunner.Physics
{
    public static class PhysicsRandomExtensions
    {
        /// <summary>
        /// Returns a vector where x and y are both bewteen 0 and 1
        /// </summary>
         public static CartesianVector NextCartesianVector(this Random random)
         {
             return new CartesianVector((float) random.NextDouble(), (float) random.NextDouble());
         }

        /// <summary>
        /// Returns a random vector between min and max
        /// </summary>
         public static CartesianVector NextCartesianVector(this Random random, CartesianVector min, CartesianVector max)
         {
             var scale = random.NextCartesianVector();
             var delta = max - min;
             return new CartesianVector(min.X + scale.X*delta.X, min.Y + scale.Y*delta.Y);
         }

         /// <summary>
         /// Returns a vector where x and y are both bewteen 0 and 1
         /// </summary>
         public static CartesianPoint NextCartesianPoint(this Random random)
         {
             return new CartesianPoint((float)random.NextDouble(), (float)random.NextDouble());
         }

         /// <summary>
         /// Returns a random vector between min and max
         /// </summary>
         public static CartesianPoint NextCartesianPoint(this Random random, CartesianPoint min, CartesianPoint max)
         {
             CartesianVector scale = random.NextCartesianVector();
             CartesianVector delta = max - min;
             return new CartesianPoint(min.X + scale.X * delta.X, min.Y + scale.Y * delta.Y);
         }
    }
}